<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>

<table width="600" border="0" cellspacing="0" cellpadding="0">
    <tr bgcolor="#EEEEEE" align="center">
        <td>Name</td>
        <td>Phone</td>
        <td>Qualification</td>
        <td>Gender</td>
    </tr>
    
    <%
    String query="SELECT * FROM employee";
    Connection db_conn = null;
    Statement statement = null;
    PreparedStatement pstmt;
    ResultSet rs;
    try{
    Class.forName("com.mysql.jdbc.Driver");
    String url= "jdbc:mysql://localhost:3306/db";
    db_conn = DriverManager.getConnection( url,"root", "root" );
    statement = db_conn.createStatement();
    rs=statement.executeQuery(query);
    while (rs.next()) { // parse the results
    out.println("<tr bgcolor='"+"'"+"#FFFFFF'"+"'"+" align='"+"'"+"center"+"'"+">");
    out.println("<td>"+rs.getString("name")+"</td>");
    out.println("<td>"+rs.getString("phone")+"</td>");
    out.println("<td>"+rs.getString("qualificaton")+"</td>");
    out.println("<td>"+rs.getString("gender")+"</td>");
    out.println("</tr>");
    }
    db_conn.close();
    } catch(SQLException e){
    e.printStackTrace();
    out.println("sql not found");
    out.println(e);
    } catch(ClassNotFoundException e){
    e.printStackTrace();
    out.println(e);
    }
    %> 
    
</table>